package com.kucai.yifaqapp.presenter.activity;

import android.content.SharedPreferences;
import android.support.annotation.StringRes;

import com.kucai.yifaqapp.ui.activity.BaseActivity;

/**
 * Created by Administrator on 2017/8/4.
 * ActivityPresenter基类
 *
 * 构造基本逻辑与添加常用方法
 */

public abstract class BaseActivityPresenter<T extends BaseActivity> {
    T mActivity;

    BaseActivityPresenter(T mActivity) {
        this.mActivity = mActivity;
    }

    SharedPreferences getSharedPreferences(){
        return mActivity.getSharedPreferences();
    }

    /**
     * 从资源文件获取String
     *
     * @param stringRes
     * @return
     */
    String getString(@StringRes int stringRes) {
        return mActivity.getString(stringRes);
    }

    /**
     * 从SharedPreferences获取String
     *
     * @param key
     * @param defValue
     * @return
     */
    String getStringFromSP(String key, String defValue) {
        return mActivity.getSharedPreferences().getString(key, defValue);
    }
}
